/**
 *
 * © Bahadir Zeren 2011
 * bzeren@gmail.com
 * No warranties, express or implied, are made for this program.
 *
 */

package org.baatar.opt.genetic.selection;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import org.baatar.opt.genetic.chromosome.IChromosome;

/**
 * Interface for the selection operators.
 *
 */
public interface ISelection<T> extends Serializable {
    /**
     * Selects a chromosome for reproduction (crossover) according to the 
     * algorithm of the implementing class.
     * 
     * @param population current population  of the genetic optimizer.
     * @param comparator Comparator implementation for chromosomes. It will 
     * work in order to meet optimization goal.
     * 
     * @return IChromosome selected chromosome object.
     */
    public IChromosome<T> selectChromosomeForReproduction(IChromosome<T>[] population,
                                                            Comparator<IChromosome<T>> comparator);

    /**
     * Selects a chromosome for population replacement (survival) according to 
     * the algorithm of the implementing class and returns its index.
     * 
     * @param chromosomeList current total population (population + children) of 
     * the genetic optimizer.
     * @param comparator Comparator implementation for chromosomes. It will 
     * work in order to meet optimization goal.
     * 
     * @return Integer index of the selected chromosome object.
     */
    public Integer selectChromosomeIndexForSurvival(ArrayList<IChromosome<T>> chromosomeList,
                                                    Comparator<IChromosome<T>> comparator);
}
